var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, i) {
    var o, a = arguments.length, r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, n) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, n, i); else for (var s = t.length - 1; 0 <= s; s--) (o = t[s]) && (r = (a < 3 ? o(r) : 3 < a ? o(e, n, r) : o(e, n)) || r);
    return 3 < a && r && Object.defineProperty(e, n, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("AudioManager"), s = e("Global"), c = e("EggsArmItemView"), l = e("MyProfitView"), d = e("GameData"), u = e("EggsManager"), p = e("DataManager"), h = e("LoadManager"), f = e("UIManager"), g = cc._decorator, m = g.ccclass, y = g.property, v = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.infoList = [ {
            id: 0,
            scale: 1.4,
            y: -69
        }, {
            id: 1,
            scale: 1.4,
            y: -69
        }, {
            id: 2,
            scale: 1.4,
            y: -67
        }, {
            id: 3,
            scale: 1.4,
            y: -66
        }, {
            id: 4,
            scale: 1.4,
            y: -66
        }, {
            id: 5,
            scale: 1,
            y: -59
        }, {
            id: 6,
            scale: 1,
            y: -54
        }, {
            id: 7,
            scale: 1,
            y: -46
        }, {
            id: 8,
            scale: 1,
            y: -54
        }, {
            id: 9,
            scale: 1,
            y: -54
        } ], t.inSprite = null, t.outSprite = null, t.infoLabel = null, t.freeLabel = null, 
        t.useBtn = null, t.lockBtn = null, t.toggleContainer = null, t.armItem = null, t.armItems = [], 
        t.gunIdx = null, t.isInit = !1, t;
    }
    return i(t, e), t.prototype.onEnable = function() {
        e.prototype.onEnable.call(this), this.isInit || (this.isInit = !0, this.init());
    }, t.prototype.onClickUseBtn = function(t) {
        r.default.getInstance().playAudio("按钮2"), this.pushEvent("免费使用" + s.G.eggGunModelList[this.gunIdx].m), 
        this.callback(t);
    }, t.prototype.init = function() {
        var n = this;
        this.armItems.push(this.armItem);
        var t = s.G.eggGunModelList.filter(function(t) {
            return -2 != u.default.getInstance().checkEggGun(t.id);
        }), e = t.filter(function(t) {
            return -1 < u.default.getInstance().checkEggGun(t.id);
        }), i = t.filter(function(t) {
            return u.default.getInstance().checkEggGun(t.id) < 0;
        });
        if (0 < e.length) {
            for (var o = e.length - 2; 0 <= o; o--) {
                var a = e[o];
                (l = (r = cc.instantiate(this.armItem.node)).getComponent(c.default)) && (l.init(a.id), 
                r.parent = this.toggleContainer.node, this.armItems.push(l));
            }
            for (o = i.length - 1; 0 <= o; o--) a = i[o], (l = (r = cc.instantiate(this.armItem.node)).getComponent(c.default)) && (l.init(a.id), 
            r.parent = this.toggleContainer.node, this.armItems.push(l));
            this.armItem.init(e[e.length - 1].id);
        } else {
            for (o = i.length - 2; 0 <= o; o--) {
                var r, l, a = i[o];
                (l = (r = cc.instantiate(this.armItem.node)).getComponent(c.default)) && (l.init(a.id), 
                r.parent = this.toggleContainer.node, this.armItems.push(l));
            }
            this.armItem.init(i[i.length - 1].id);
        }
        this.gunIdx = this.armItem.gunIdx, this.armItems.forEach(function(t) {
            var e = new cc.Component.EventHandler();
            e.target = n.node, e.component = "EggsArmView", e.handler = "changeArm", t.toggle.checkEvents.push(e);
        }), this.refresh();
    }, t.prototype.callback = function() {
        d.GD.gunIdx = this.gunIdx + 1e3, u.default.getInstance().updateEggGun(this.gunIdx), 
        p.default.getInstance().save(), 4 < this.gunIdx ? f.default.getInstance().loadPopPnl("egg_reward", {
            type: s.RewardType.ARM,
            idx: d.GD.gunIdx,
            scale: 1.6
        }) : f.default.getInstance().loadPopPnl("egg_combine"), this.refresh(), this.delayBtn();
    }, t.prototype.changeArm = function(t) {
        t = t.target;
        t && (t = t.getComponent(c.default), this.gunIdx = t.gunIdx, this.refresh());
    }, t.prototype.refresh = function(e) {
        void 0 === e && (e = this.gunIdx);
        var t = this.infoList.filter(function(t) {
            return t.id == e;
        });
        0 < t.length && (this.inSprite.node.scale = t[0].scale, this.inSprite.node.y = t[0].y);
        t = s.G.eggGunModelList.filter(function(t) {
            return t.id == e;
        });
        0 < t.length && (h.default.getInstance().loadSpriteFrame({
            url: "image/eggs/彩蛋墙" + t[0].m + "@2x",
            sprite: this.inSprite
        }), h.default.getInstance().loadSpriteFrame({
            url: "image/eggs/" + t[0].m + "外框@2x",
            sprite: this.outSprite
        }), this.infoLabel.string = t[0].j), GA.Info.underCheck ? (this.freeLabel.node.parent.active = !0, 
        this.inSprite.node.active = !0, this.lockBtn.active = !1, this.myButton.node.active = !0, 
        this.useBtn.node.active = !1, this.freeLabel.string = "今日免费使用次数：0") : (t = u.default.getInstance().checkEggGun(e)) < 0 ? this.showLock() : 0 < t ? (this.freeLabel.node.parent.active = !0, 
        this.inSprite.node.active = !0, this.lockBtn.active = !1, this.myButton.node.active = !1, 
        this.useBtn.node.active = !0, this.freeLabel.string = "今日免费使用次数：" + t) : (this.freeLabel.node.parent.active = !0, 
        this.inSprite.node.active = !0, this.lockBtn.active = !1, this.myButton.node.active = !0, 
        this.useBtn.node.active = !1, this.freeLabel.string = "今日免费使用次数：0");
    }, t.prototype.showLock = function() {
        this.freeLabel.node.parent.active = !1, this.inSprite.node.active = !1, this.lockBtn.active = !0, 
        this.myButton.node.active = !1, this.useBtn.node.active = !1;
    }, a([ y(cc.Sprite) ], t.prototype, "inSprite", void 0), a([ y(cc.Sprite) ], t.prototype, "outSprite", void 0), 
    a([ y(cc.Label) ], t.prototype, "infoLabel", void 0), a([ y(cc.Label) ], t.prototype, "freeLabel", void 0), 
    a([ y(cc.Button) ], t.prototype, "useBtn", void 0), a([ y(cc.Node) ], t.prototype, "lockBtn", void 0), 
    a([ y(cc.ToggleContainer) ], t.prototype, "toggleContainer", void 0), a([ y(c.default) ], t.prototype, "armItem", void 0), 
    a([ m ], t);
}(l.default);

n.default = v;